package com.oracle.lingshangejia.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.oracle.lingshangejia.R;
import com.oracle.lingshangejia.base.BaseActivity;
import com.oracle.lingshangejia.searchview.ICallBack;
import com.oracle.lingshangejia.searchview.SearchView;
import com.oracle.lingshangejia.searchview.bCallBack;

public class SearchActivity extends BaseActivity implements View.OnClickListener {
    // 1. 初始化搜索框变量
    private SearchView searchView;
    private TextView tv_title;
    private ImageButton ib_back;
    @Override
    public int intiLayout() {
        return R.layout.activity_search;
    }

    @Override
    public void initView() {
        // 3. 绑定组件
        searchView = (SearchView) findViewById(R.id.search_view);
        tv_title=findViewById(R.id.tv_title);
        ib_back=findViewById(R.id.ib_back);
        ib_back.setOnClickListener(this);
        tv_title.setText("搜索");
        // 4. 设置点击搜索按键后的操作（通过回调接口）
        // 参数 = 搜索框输入的内容
        searchView.setOnClickSearch(new ICallBack() {
            @Override
            public void SearchAciton(String string) {
                System.out.println("我收到了" + string);
                Intent intent=new Intent(SearchActivity.this,SearchResidentActivity.class);
                intent.putExtra("key",string);
                startActivity(intent);
            }
        });

        // 5. 设置点击返回按键后的操作（通过回调接口）
        searchView.setOnClickBack(new bCallBack() {
            @Override
            public void BackAciton() {
                finish();
            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ib_back:
                finish();
                break;
        }
    }
}
